import logo from './logo.svg';
import './App.css';
import React, { useEffect, useState } from 'react';
import { click } from '@testing-library/user-event/dist/click';


function Bpp(){
  const[state,setState]=useState(true)
    function click(){
      setState(false)
    }
    return (
      <div>
       {state&&<App/>}
       <button onClick={click}>隐藏</button>
       
      </div>
    )

}


function App(){

  const [count,setCount]=useState(0)

  
  useEffect(()=>{
    console.log('count发生变化了');
    return ()=>{
      console.log('组件隐藏');
    }
  })

  function click1(){
    setCount(count+1)
  }
 
   return (
    <div>
      <div>{count}</div>
      <button onClick={click1}>加一</button>
    </div>
   )
}

export default Bpp;
